﻿package net.wangit.dev.tree;

import net.wangit.jdbc.DB;
import net.wangit.util.Checker;
import net.wangit.view.page.PageCache;
import net.wangit.view.unit.UnitCache;

public class TreeReferenceUtil {

	private static final String SQL_REFERENCE = "update ELEMENT set r=? where c=85 and r=?";

	public TreeReferenceUtil() {
	}

	public static void update(DB db, String domain, String oldTreeId,
			String newTreeId) throws Exception {
		if (!Checker.isEmpty(oldTreeId) && !oldTreeId.equals(newTreeId)) {
			db.execute(TreeReferenceUtil.SQL_REFERENCE, new String[] {
					newTreeId, oldTreeId }, new int[] { 2, 2 });
			UnitCache.clearAll(domain);
			PageCache.clearAll(domain);
		}
	}
}
